Send Message
The MessageUI namespace provides functions to detect messaging capabilities and present a system message compose view from within a script. You can send SMS or MMS messages with optional subject and attachments, depending on device capabilities.
Availability Properties
MessageUI.isAvailable: boolean
Returns true if the device is capable of sending plain text messages.
MessageUI.canSendSubject: boolean
Returns true if the device supports adding a subject to messages.
MessageUI.canSendAttachments: boolean
Returns true if the device supports including attachments in messages.
MessageUI.present(options): Promise<"cancelled" | "sent" | "failed">
Displays the system’s message composer with the specified content and resolves with the result of the user’s action.
Parameters
Attachment Object
Each item in the attachments array must include:
Return Value
Returns a Promise that resolves to one of the following values:
"sent": The message was successfully sent by the user."cancelled": The user canceled the message."failed": The message failed to send due to an error (e.g., connectivity or system failure).
Example: Basic Text Message
Example: Message with Subject and Attachment
Notes
- The
subjectandattachmentsoptions are automatically ignored if not supported on the device. - This API only presents the UI; sending is user-controlled.
- Can only be used in interactive scripts (not background-only scripts).
